package com.smz.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.smz.entity.TCargo;
import com.smz.service.TCargoService;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@Api
@RestController
public class InquireController {
    @Autowired
    private TCargoService tCargoService;


    /**
      * @Authoe: smz
      * @Description: 分页查询
      * @Date: 15:18 2021-11-24
      */
    @GetMapping("/inquires/{wareId}/{shelveNo}/{dameId}")
    public ResponseEntity<IPage<TCargo>> findAll(@PathVariable("wareId") String wareId,
                                                 @PathVariable("shelveNo") String shelvesNo, @PathVariable("dameId") String dameId,
                                                 @RequestParam("size") Integer size, @RequestParam("current") Integer current){
        IPage<TCargo> pageTCargo = tCargoService.findPageTCargo(size, current,dameId , wareId,shelvesNo );
        return  ResponseEntity.ok(pageTCargo);
    }

    /**
      * @Authoe: smz
      * @Description: 三个搜索框条件搜索
      * @Date: 15:19 2021-11-24
      */
    @GetMapping(value = "/inquire/{wareId}/{pNumber}/{pName}/{size}/{current}",produces = "application/json;charset=utf-8")
    public ResponseEntity<IPage<TCargo>> findTCargoByWareIdAndPNumberAndPName(@PathVariable("wareId") String wareId,
                                                                              @PathVariable("pNumber") String pNumber,
                                                                              @PathVariable("pName") String pName,
                                                                              @PathVariable("size") int size,
                                                                              @PathVariable("current") int current
                                                                             ){

        IPage<TCargo> tCargos = tCargoService.selectTCargoByWareId(wareId, pNumber, pName,size,current);
        return ResponseEntity.ok(tCargos);
    }


}
